#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

vector<int> div(vector<int>& A,int b,int &r)
{
    vector<int> ret;
    for(int i=A.size()-1;i>=0;--i)
    {
        r=r*10+A[i];
        ret.push_back(r/b);
        r%=b;
    }
    reverse(ret.begin(),ret.end());
    while(ret.size()>1&&ret.back()==0) ret.pop_back();
    
    return ret;
}

int main()
{
    string a;
    int b;
    
    vector<int> A;
    cin>>a>>b;
    for(int i=a.size()-1;i>=0;--i)
        A.push_back(a[i]-'0');
    int r=0;
    auto ret=div(A,b,r);
    for(int i=ret.size()-1;i>=0;--i)
        cout<<ret[i];
    cout<<endl<<r;
    return 0;
}